<?php defined("MAIN_DIR") or die("No direct access");

$currencies = array();
while ($cur_row = mysql_fetch_array($cur_res))
{
	if ($cur_row['currency'] == 'RUB')
	{
		$currencies['rub']['s_l'] = $cur_row['sum_low'];
		$currencies['rub']['s_h'] = $cur_row['sum_high'];
		$currencies['rub']['p_l'] = $cur_row['period_low'];
		$currencies['rub']['p_h'] = $cur_row['period_high'];
		$currencies['rub']['r_l'] = $cur_row['rate_low'];
		$currencies['rub']['r_h'] = $cur_row['rate_high'];
	}
	elseif ($cur_row['currency'] == 'USD')
	{
		$currencies['usd']['s_l'] = $cur_row['sum_low'];
		$currencies['usd']['s_h'] = $cur_row['sum_high'];
		$currencies['usd']['p_l'] = $cur_row['period_low'];
		$currencies['usd']['p_h'] = $cur_row['period_high'];
		$currencies['usd']['r_l'] = $cur_row['rate_low'];
		$currencies['usd']['r_h'] = $cur_row['rate_high'];
	}
	elseif ($cur_row['currency'] == 'EUR')
	{
		$currencies['eur']['s_l'] = $cur_row['sum_low'];
		$currencies['eur']['s_h'] = $cur_row['sum_high'];
		$currencies['eur']['p_l'] = $cur_row['period_low'];
		$currencies['eur']['p_h'] = $cur_row['period_high'];
		$currencies['eur']['r_l'] = $cur_row['rate_low'];
		$currencies['eur']['r_h'] = $cur_row['rate_high'];
	}
}
?>
<table cellpadding='5' cellspacing='0'>
	<tr>
		<td width="80px">Валюта</td>
		<td width="330px">Сумма</td>
		<td width="200px">Срок (месяцы)</td>
		<td width="200px">Ставка (%)</td>
	</tr>	
	<tr id="RUB">
		<td>
			<input type='checkbox' name='RUB' id='check_RUB' <?php
			if (isset($currencies['rub']))
				echo " checked='checked'";?> /> RUB</td>
		<td>от <input style='width:130px' type='text' name='RUB_sum_low' <?php
				if (!isset($currencies['rub'])) echo "disabled='disabled'";
				else echo "value='".$currencies['rub']['s_l']."'"; ?> />
			до <input style='width:130px' type='text' name='RUB_sum_high' <?php
				if (!isset($currencies['rub'])) echo "disabled='disabled'";
				else echo "value='".$currencies['rub']['s_h']."'"; ?> /></td>
		<td>от <input style='width:50px' type='text' name='RUB_period_low' <?php
				if (!isset($currencies['rub'])) echo "disabled='disabled'";
				else echo "value='".$currencies['rub']['p_l']."'"; ?> />
			до <input style='width:50px' type='text' name='RUB_period_high' <?php
				if (!isset($currencies['rub'])) echo "disabled='disabled'";
				else echo "value='".$currencies['rub']['p_h']."'"; ?> /></td>
		<td>от <input style='width:50px' type='text' name='RUB_rate_low' <?php
				if (!isset($currencies['rub'])) echo "disabled='disabled'";
				else echo "value='".$currencies['rub']['r_l']."'"; ?> />
			до <input style='width:50px' type='text' name='RUB_rate_high' <?php
				if (!isset($currencies['rub'])) echo "disabled='disabled'";
				else echo "value='".$currencies['rub']['r_h']."'"; ?> /></td>
	</tr>
	<tr id="USD">
		<td>
			<input type='checkbox' name='USD' id='check_USD' <?php
			if (isset($currencies['usd']))
				echo " checked='checked'";?> /> USD</td>
		<td>от <input style='width:130px' type='text' name='USD_sum_low' <?php
				if (!isset($currencies['usd'])) echo "disabled='disabled'";
				else echo "value='".$currencies['usd']['s_l']."'"; ?> />
			до <input style='width:130px' type='text' name='USD_sum_high' <?php
				if (!isset($currencies['usd'])) echo "disabled='disabled'";
				else echo "value='".$currencies['usd']['s_h']."'"; ?> /></td>
		<td>от <input style='width:50px' type='text' name='USD_period_low' <?php
				if (!isset($currencies['usd'])) echo "disabled='disabled'";
				else echo "value='".$currencies['usd']['p_l']."'"; ?> />
			до <input style='width:50px' type='text' name='USD_period_high' <?php
				if (!isset($currencies['usd'])) echo "disabled='disabled'";
				else echo "value='".$currencies['usd']['p_h']."'"; ?> /></td>
		<td>от <input style='width:50px' type='text' name='USD_rate_low' <?php
				if (!isset($currencies['usd'])) echo "disabled='disabled'";
				else echo "value='".$currencies['usd']['r_l']."'"; ?> />
			до <input style='width:50px' type='text' name='USD_rate_high' <?php
				if (!isset($currencies['usd'])) echo "disabled='disabled'";
				else echo "value='".$currencies['usd']['r_h']."'"; ?> /></td>
	</tr>
	<tr id="EUR">
		<td>
			<input type='checkbox' name='EUR' id='check_EUR' <?php
			if (isset($currencies['eur']))
				echo " checked='checked'";?> /> EUR</td>
		<td>от <input style='width:130px' type='text' name='EUR_sum_low' <?php
				if (!isset($currencies['eur'])) echo "disabled='disabled'";
				else echo "value='".$currencies['eur']['s_l']."'"; ?> />
			до <input style='width:130px' type='text' name='EUR_sum_high' <?php
				if (!isset($currencies['eur'])) echo "disabled='disabled'";
				else echo "value='".$currencies['eur']['s_h']."'"; ?> /></td>
		<td>от <input style='width:50px' type='text' name='EUR_period_low' <?php
				if (!isset($currencies['eur'])) echo "disabled='disabled'";
				else echo "value='".$currencies['eur']['p_l']."'"; ?> />
			до <input style='width:50px' type='text' name='EUR_period_high' <?php
				if (!isset($currencies['eur'])) echo "disabled='disabled'";
				else echo "value='".$currencies['eur']['p_h']."'"; ?> /></td>
		<td>от <input style='width:50px' type='text' name='EUR_rate_low' <?php
				if (!isset($currencies['eur'])) echo "disabled='disabled'";
				else echo "value='".$currencies['eur']['r_l']."'"; ?> />
			до <input style='width:50px' type='text' name='EUR_rate_high' <?php
				if (!isset($currencies['eur'])) echo "disabled='disabled'";
				else echo "value='".$currencies['eur']['r_h']."'"; ?> /></td>
	</tr>
</table>